package com.aaa.member.controller;

import com.aaa.common.util.Result;
import com.aaa.member.entity.MemberLevel;
import com.aaa.member.service.MemberLevelService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * (MemberLevel)表控制层
 *
 * @author YuXin
 * @since 2020-11-18 18:58:34
 */
@RestController
@RequestMapping("memberLevel")
public class MemberLevelController {
    /**
     * 服务对象
     */
    @Resource
    private MemberLevelService memberLevelService;


    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("selectOne")
    public MemberLevel selectOne(Long id) {
        return this.memberLevelService.queryById(id);
    }

    /**
     * 查询指定行数据
     *
     * @param pageNo      查询起始位置
     * @param pageSize    查询条数
     * @param memberLevel
     * @return Result ---- Result.getData() 对象列表
     */
    @GetMapping("queryAllByParam")
    public Result queryAllByParam(Integer pageNo, Integer pageSize, MemberLevel memberLevel) {
        return this.memberLevelService.queryAllByParam(pageNo, pageSize, memberLevel);
    }

    /**
     * 新增数据
     *
     * @param memberLevel 实例对象
     * @return 实例对象
     */
    @PostMapping("insert")
    public MemberLevel insert(@RequestBody MemberLevel memberLevel) {
        this.memberLevelService.insert(memberLevel);
        return memberLevel;
    }

    /**
     * 修改数据
     *
     * @param memberLevel 实例对象
     * @return 实例对象
     */
    @PutMapping("update")
    public MemberLevel update(@RequestBody MemberLevel memberLevel) {
        return this.memberLevelService.update(memberLevel);
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @DeleteMapping("deleteById")
    public boolean deleteById(Long id) {
        return this.memberLevelService.deleteById(id);
    }
}